﻿@using Website.Models.Domain
@model Website.Models.ViewModels.ProfilesView
@{
    this.ViewBag.Title = "Opret Profil";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
    var errorMsg = new HtmlString(string.Empty);
    var profile = this.ViewData["Profile"] as Website.CRUDServices.Profile ?? new Website.CRUDServices.Profile();
    if (this.ViewData["ErrorMessage"] != null)
    {
        errorMsg = this.ViewData["ErrorMessage"] as HtmlString;
    }

}

@using (this.Html.BeginForm())
{
    <div class="error">
        @errorMsg
    </div>

    <div class="formBullet">Navn*:</div>
    <div class="formEntry">
        <input type="text" name="Name" tabindex="1" autofocus="autofocus" value="@profile.Name" /></div>

    <div class="formBullet">CVR:</div>
    <div class="formEntry">
        <input type="text" name="CVR" tabindex="2" value="@profile.CVR" /></div>

    <div class="formBullet">Relation*:</div>
    <div class="formEntry">
        <select name="Relation"  tabindex="3" >
            <option value="@Guid.Empty">Vælg en relation</option>
            @foreach (ProfileRelation rel in this.Model.Relations.OrderBy(x => x.Type))
            {
                string selected = rel.ID.Equals(profile.Relation) ? " selected=\"selected\" " : string.Empty;
                <option value="@rel.ID" @selected>@rel.Type</option>
            }
        </select>
    </div>

    <div class="formBullet">Kontakt type:</div>
    <div class="formEntry">
        <select name="ContactType" tabindex="4" >
            <option value="@Guid.Empty">Vælg en kontakt-type</option>
            @foreach (ProfileContactType c in this.Model.ContactTypes.OrderBy(x => x.Type))
            {
                string selected = c.ID.Equals(profile.ContactType) ? " selected=\"selected\" " : string.Empty;
                <option value="@c.ID" @selected>@c.Type</option>
            }
        </select>
    </div>

    <div class="formBullet">Sektor og type*:</div>
    <div class="formEntry">
        <select name="SubType" tabindex="5" >
            <option value="@Guid.Empty">Vælg en type</option>
            @foreach (ProfileSubtype typ in this.Model.Subtypes.OrderBy(x => x.Type.Sector.Name).ThenBy(x => x.Type.Name).ThenBy(x => x.Name))
            {
                string selected = typ.ID.Equals(profile.SubType) ? " selected=\"selected\" " : string.Empty;
                <option value="@typ.ID" @selected>
                    @typ.Type.Sector.Name - 
                    @typ.Type.Name
                    @if (!typ.Name.Equals(string.Empty))
                    {
                        @Html.Label(string.Format(" - {0}", typ.Name))
                    }

                </option>
            }
        </select>
    </div>
    
    <div class="formBullet">Inden for 150km?</div>
    <div class="formEntry">
        <input type="radio" name="Within150Km" value="true" checked="checked" />Ja<br />
        <input type="radio" name="Within150Km" value="false" />Nej
    </div>
    
    <div class="formBullet">Er iværksætter?</div>
    <div class="formEntry">
        <input type="radio" name="IsEntrepreneur" value="true" />Ja<br />
        <input type="radio" name="IsEntrepreneur" value="false" checked="checked" />Nej
    </div>
    
    
    
    <div class="formBullet">
        Region:
    </div>
    <div class="formEntry">
        <select name="Region">
            <option value="">Vælg en region</option>
            @foreach (Region reg in Model.Regions.OrderBy(x => x.Country.Name).ThenBy(x => x.Name))
            {
                <option value="@reg.ID">@reg.Country.Name - @reg.Name</option>
            }
        </select>
    </div>
    
    <div class="formBullet">Ved valg af Region Syddanmark, er det i udkantsområde?</div>
    <div class="formEntry">
        <input type="radio" name="IsRemoteArea" value="true" />Ja<br />
        <input type="radio" name="IsRemoteArea" value="false" checked="checked" />Nej
    </div>

    <div class="buttonHolder">
        <input type="submit" value="Opret" tabindex="7" /></div>
}


